JavaScript: Intermediate JavaScript Coding From The Ground Up (DIY JavaScript Book 2) by Dvorjak Keith

JavaScript: Intermediate JavaScript Coding From The Ground Up (DIY JavaScript Book 2) by Dvorjak Keith
Author: Dvorjak, Keith [Dvorjak, Keith]
Language: eng
Format: epub
Published: 2017-10-01

Chapter 9

Error handling

What are errors?

Errors are basically unexpected conditions that may or may not halt the execution of a program during the runtime of a program. Errors can arise due to programmer’s mistake, unexpected input or other such reasons. Any program is prone to errors. Hence it becomes necessary to have a way of handling them without disrupting program’s flow or have an alternative flow to make sure the application doesn’t function in an unexpected manner.

Handling errors

In JavaScript error handling is done with the help of four statements: 'try,' ‘catch,' ‘finally,' and ‘throw.'